import com.badlogic.gdx.ApplicationAdapter
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.backends.lwjgl.LwjglApplication
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.GL10
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g2d.TextureRegion

fun main(args: Array<String>)
{
    val config = LwjglApplicationConfiguration()
    config.width = 480
    config.height = 320
    config.useGL20 = true
    config.backgroundFPS = 30
    config.foregroundFPS = 120
    config.initialBackgroundColor = Color.GRAY
    config.resizable = false
    config.title = "ImageRender"
    LwjglApplication(MainPage(), config)
}

class MainPage : ApplicationAdapter()
{
    private val texture by lazy {
        Texture(Gdx.files.internal("aiweier.jpg"))
    }

    private val batch by lazy {
        SpriteBatch()
    }

    private val leftRegion by lazy {
        TextureRegion(texture, 0, 0, 512, 512)
    }
    private val rightRegion by lazy {
        TextureRegion(texture, 512, 0, 512, 512)
    }

    override fun render()
    {
        clear()
        batch.begin()
        
//        batch.draw(texture, 0f, 0f, Gdx.graphics.floatWidth, Gdx.graphics.floatHeight)
        batch.draw(rightRegion, 0f, 0f, Gdx.graphics.floatWidth, Gdx.graphics.floatHeight)
        
        
        batch.end()
    }
}